#define _CRT_SECURE_NO_WARNINGS



#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int>PII;
typedef long long LL;
const int N = 1e5 + 10;
int n, m;
int s, t;
LL res = 0x3f3f3f3f;
vector<PII>edges[N];
bool st[N];
LL dist[N];
LL dijkstra(int p)
{
	memset(dist, 0x3f, sizeof dist);
	memset(st, 0, sizeof st);

	priority_queue<PII, vector<PII>, greater<PII>>heap;
	heap.push({ 0,p });
	dist[p] = 0;
	while (heap.size())
	{
		auto t = heap.top();
		heap.pop();
		int u = t.second;

		if (st[u])
			continue;
		st[u] = true;

		for (auto& t : edges[u])
		{
			int v = t.first;
			int w = t.second;
			if (dist[u] + w < dist[v])
			{
				dist[v] = dist[u] + w;
				heap.push({ dist[v],v });
			}
		}
	}
	return dist[t];
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		edges[u].push_back({ v,w });
		edges[v].push_back({ u,w });
	}
	cin >> s >> t;
	//for (int i = 1; i <= s; i++)
	//{
	//	int x;
	//	cin >> x;
	//	ret = min(dijkstra(x), ret);
	//}
	dijkstra(t);
	for (int i = 1; i <= s; i++)
	{
		int x;
		cin >> x;
		res = min(dist[x], res);
	}
	cout << res;
	return 0;
}

